﻿<UserControl x:Class="PairingMatrix.View.ProjectCardControl" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:Interactivity="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity" xmlns:Behavior="clr-namespace:PairingMatrix.View.Behavior" xmlns:Converter="clr-namespace:PairingMatrix.View.Converter" xmlns:AttachedProperty="clr-namespace:PairingMatrix.View.AttachedProperty" xmlns:View="clr-namespace:PairingMatrix.View" mc:Ignorable="d" d:DataContext="{Binding Source={StaticResource ProjectCard}}" Background="White">

	<UserControl.Resources>
		<Converter:BoolToColorHighlightConverter x:Key="boolToColorHighlightConverter" />
		<Converter:BoolToVisibilityConverter x:Key="boolToVisibilityConverter" />
		<Converter:BoolToScaleHighlightConverter x:Key="boolToScaleHighlightConverter" />
		<Converter:UrgencyToColorConverter x:Key="urgencyToColorConverter" />
        <Converter:PriorityToColorConverter x:Key="priorityToColorConverter" />
	</UserControl.Resources>

    <Grid Name="CardGrid">
        <Grid x:Name="notes" Height="50" Margin="50,130,0,0" Width="160" Background="Orange" HorizontalAlignment="Left" VerticalAlignment="Top">
            <TextBox Background="Transparent" Text="{Binding Path=Note, Mode=TwoWay}" FontSize="14" AttachedProperty:BindingHelper.UpdateSourceOnChange="True" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" Height="50" TextWrapping="Wrap" />
        </Grid>
        <Border Visibility="Visible" Opacity="1"  Height="135" VerticalAlignment="Top">
			<Border.Effect>
				<DropShadowEffect BlurRadius="16" Color="{Binding Path=ShowHighlighted, Converter={StaticResource boolToColorHighlightConverter}}" Direction="235" Opacity=".5" ShadowDepth="0" />
			</Border.Effect>

			<Grid x:Name="LayoutRoot" Background="Transparent" VerticalAlignment="Top">
                <Grid VerticalAlignment="Top" Margin="0" Visibility="{Binding Path=ShowDaysSpentForProjectCards, Converter={StaticResource boolToVisibilityConverter}}">
					<Ellipse Width="40" Height="30" Fill="Wheat" VerticalAlignment="Top" />
					<TextBlock Text="{Binding Path=NumberOfSignUps}" HorizontalAlignment="Center" VerticalAlignment="Top" FontFamily="Fonts/Fonts.zip#Consolas" FontSize="19" />
				</Grid>
				<StackPanel Background="White" Margin="0,22,0,0" Width="180">
					<Grid Background="{Binding Path=Urgency, Converter={StaticResource urgencyToColorConverter}}" Height="20">
						<TextBlock Text="{Binding Path=CardNumber}" FontWeight="Bold" Margin="5,2,0,0" FontSize="15" />
						<!--                <TextBox x:Name="cardnum" Text="{Binding Path=CardNumber, Mode=TwoWay}" AttachedProperty:BindingHelper.UpdateSourceOnChange="True" FontWeight="Bold" Margin="5,-2,0,0" IsEnabled="{Binding Path=IsInEditMode}" Visibility="{Binding Path=IsInEditMode, Converter={StaticResource boolToVisibilityConverter}}" IsEnabledChanged="cardnum_IsEnabledChanged"/>-->
						<!--                <TextBlock Text="{Binding Path=CenterPoint.X}" FontWeight="Bold" Margin="110,2,0,0"/>-->
						<Button Height="15" Width="15" Content="X" FontSize="12" Padding="-2" Margin="0,2,5,0" HorizontalAlignment="Right" VerticalAlignment="Top" Command="{Binding Path=RemoveFromWallCommand}" />
						<Button Height="15" Width="15" Content="*" FontSize="16" Padding="0" Margin="0,2,22,0" HorizontalAlignment="Right" VerticalAlignment="Top" Command="{Binding Path=ToggleEditModeCommand}" />
						<Button Height="15" Width="15" FontSize="16" Padding="0" Margin="0,2,39,0" HorizontalAlignment="Right" VerticalAlignment="Top" Command="{Binding Path=ToggleNotesVisibilityCommand}">
							<Button.Content>
								<Rectangle Fill="Orange" Height="15" Width="15" />
							</Button.Content>
						</Button>
					</Grid>
					<Grid Height="70">
						<TextBlock Text="{Binding Path=Title}" VerticalAlignment="Stretch" Margin="12,3,5,5" FontSize="15" HorizontalAlignment="Stretch" Height="80" TextWrapping="Wrap" />
						<TextBox x:Name="title" Text="{Binding Path=Title, Mode=TwoWay}" FontSize="15" AttachedProperty:BindingHelper.UpdateSourceOnChange="True" VerticalAlignment="Stretch" Margin="10,0,5,5" HorizontalAlignment="Stretch" Height="80" TextWrapping="Wrap" IsEnabled="{Binding Path=IsInEditMode}" Visibility="{Binding Path=IsInEditMode, Converter={StaticResource boolToVisibilityConverter}}" GotFocus="title_GotFocus" />
						<Image Source="/PairingMatrix;component/View/Image/SyncWithMingle.png" Visibility="{Binding Path=IsSyncing, Converter={StaticResource boolToVisibilityConverter}}" />
                        <Rectangle Width="10" Fill="{Binding Path=Priority, Converter={StaticResource priorityToColorConverter}}" HorizontalAlignment="Left"/>
					</Grid>
					<Grid>
						<TextBlock Grid.Column="0" Margin="10,2,0,0" HorizontalAlignment="Left" VerticalAlignment="Top" Text="{Binding Path=StatusInMingle}" Height="20" Foreground="Blue" />
						<TextBlock Grid.Column="0" Margin="0,2,10,0" HorizontalAlignment="Right" VerticalAlignment="Top" Text="{Binding Path=DevEstimate}" Height="20" Foreground="Blue" />
					</Grid>
				</StackPanel>
			</Grid>
		</Border>
	</Grid>
	<UserControl.RenderTransform>
		<TransformGroup>
			<ScaleTransform x:Name="scaleTransform" CenterX="55" CenterY="90" />
		</TransformGroup>
	</UserControl.RenderTransform>
	<Interactivity:Interaction.Behaviors>
		<Behavior:DragProjectCardBehavior />
		<Behavior:OpacityForProjectCardBehavior />
		<Behavior:MoveAnimationForProjectCardBehavior />
		<Behavior:HighlightProjectCardBehavior />
		<Behavior:ShowProjectCardNotesBehavior />
		<Behavior:SetZIndexOfProjectCardBehavior/>
		<Behavior:SetSecondaryCardPositionsOfProjectCardBehavior/>
	</Interactivity:Interaction.Behaviors>
</UserControl>
